﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections;

/// <summary>
/// Summary description for GooglePolygons
/// </summary>
public class GooglePolygons : CollectionBase
{
	public GooglePolygons()
	{
		//
		// TODO: Add constructor logic here
		//
	}

    public GooglePolygons Clone()
    {
        GooglePolygons p = new GooglePolygons();
        for (int i = 0; i < this.Count; i++)
        {
            GooglePolygon GPL = new GooglePolygon();
            GPL.FillColor = this[i].FillColor;
            GPL.FillOpacity = this[i].FillOpacity;
            GPL.ID = this[i].ID;
            GPL.Status = this[i].Status;
            GPL.StrokeColor = this[i].StrokeColor;
            GPL.StrokeOpacity = this[i].StrokeOpacity;
            GPL.StrokeWeight = this[i].StrokeWeight;
            GPL.ArrayPoint = this[i].ArrayPoint.Clone();
            p.Add(GPL);
        }
        return p;
    }

    public GooglePolygon this[int pIndex]
    {
        get
        {
            return (GooglePolygon)this.List[pIndex];
        }
        set
        {
            this.List[pIndex] = value;
        }
    }

    public GooglePolygon this[string pID]
    {
        get
        {
            for (int i = 0; i < Count; i++)
            {
                if (this[i].ID == pID)
                {
                    return (GooglePolygon)this.List[i];
                }
            }
            return null;
        }
        set
        {
            for (int i = 0; i < Count; i++)
            {
                if (this[i].ID == pID)
                {
                    this.List[i] = value;
                }
            }
        }
    }

    public void Add(GooglePolygon pPolygon)
    {
        this.List.Add(pPolygon);
    }
    public void Remove(int pIndex)
    {
        this.RemoveAt(pIndex);
    }
    public void Remove(string pID)
    {
        for (int i = 0; i < Count; i++)
        {
            if (this[i].ID == pID)
            {
                this.List.RemoveAt(i);
                return;
            }
        }
    }
}